package de.alex.schulzeit;

import java.util.Calendar;

/**
 * Helper class for gettint the right day numbers and strings
 * 
 * This class converts the wrong weekday start and offers methods to access strings and integers
 * 
 * @author Alexander Ruetz
 * @version 1.0
 */
public class Date {

	public final static int MONDAY = 1;
	public final static int TUESDAY = 2;
	public final static int WEDNESDAY = 3;
	public final static int THURSDAY = 4;
	public final static int FRIDAY = 5;
	public final static int SATURDAY = 6;
	public final static int SUNDAY = 7;
	private static Calendar cal = Calendar.getInstance();
	
	
	/**
	 * Returns the day as integer from 1 (Monday) to 7 (Sunday)
	 * 
	 * @return int result
	 */
	public static int getDay() {
		int result, day; 
		day = cal.get(Calendar.DAY_OF_WEEK);
		switch (day) {
		case Calendar.MONDAY:
			result = MONDAY;
		case Calendar.TUESDAY:
			result = TUESDAY;
			break;
		case Calendar.WEDNESDAY:
			result = WEDNESDAY;
			break;
		case Calendar.THURSDAY:
			result = THURSDAY;
			break;
		case Calendar.FRIDAY:
			result = FRIDAY;
			break;
		case Calendar.SATURDAY:
			result = SATURDAY;
			break;
		case Calendar.SUNDAY:
			result = SUNDAY;
			break;
		default:
			result = 0;
		}
		return result;
	}
	
	/**
	 * Returns the Resource id for the specified weekday
	 * 
	 * @param int i
	 * @return dayResult
	 */
	public static int getDay(int i) {
		int dayResult = 0;
		switch (i) {
		case 1:
			dayResult = R.string.day_monday;
			break;
		case 2:
			dayResult = R.string.day_tuesday;
			break;
		case 3:
			dayResult = R.string.day_wednesday;
			break;
		case 4:
			dayResult = R.string.day_thursday;
			break;
		case 5:
			dayResult = R.string.day_friday;
			break;
		case 6:
			dayResult = R.string.day_saturday;
			break;
		}
		return dayResult;
	}
}